#ifndef VERTEXBASE_H
#define VERTEXBASE_H
#include <string>
using namespace std;

class Group;
class Graph;
class VertexBase;

// base class for group of vertices
class VertexContainer 
{
	virtual void InsertNewVertex(VertexBase* vertex)= 0;
};

// base class for a vertex
class VertexBase
{
public:
	// returns true iff otherVertex is a neighbour of this vertex
	virtual bool Neighbours(VertexBase* otherVertex) = 0;

	// Set flags, adds other vertex to replacement list
	virtual void SetInterchangeable(VertexBase* otherVertexSet, bool updateContainer) = 0;
	// Adds vertex to m_VerticesToReplace list
	virtual void SetAsReplacementFor(VertexBase* otherVertex) = 0;

	static void VertexBase::CreateInterchangeableLink(VertexBase *interchangeableVertexBase, VertexBase *replacementVertexBase)
	{
		interchangeableVertexBase->SetInterchangeable(replacementVertexBase, true);
		replacementVertexBase->SetAsReplacementFor(interchangeableVertexBase);
	}

	virtual bool Interchangeable() = 0;
	virtual bool IsReplacement()  = 0;
	virtual bool IsInGraph() = 0;
	virtual void SetInterchangeableFlag(bool value) = 0;
	virtual void SetReplacementFlag(bool value) = 0;

	virtual bool HasNeighbourInGroup(Group *group) = 0;

	virtual Graph *GetContainingGraph() = 0;
	virtual VertexContainer* GetPreviousContainer() = 0;

	virtual bool CanBeRemovedFromReplacements() = 0;
	virtual bool CanAllRelatedInterchangeablesBeReplaced() = 0;
	virtual bool CanBeReplaced() = 0;

	virtual void ClearInterchangeableInformation() = 0;

	virtual string PrintName() = 0;

	virtual void FindReplacements(Graph *graph) = 0;
	virtual void Replace(Graph *graph) = 0;
	virtual void ReturnToOriginalContainer(bool updateLists = true) = 0;
	virtual void RemoveAllReplacements() = 0;

protected:
	// this vertex can be replaced, in the group it is in, with all vertices in m_Replacements
	bool m_Interchangeable;
	// this vertex can serve as a replacement, of any of the vertices in m_VerticesToReplace in some group
	bool m_IsReplacement;

};

class Vertex;

#endif //VERTEXBASE_H